import 'dart:convert';

import 'ChunkFile.dart';

SaveChunkFile saveChunkFileFromJson(String str) =>
    SaveChunkFile.fromJson(json.decode(str));

String saveChunkFileToJson(SaveChunkFile data) => json.encode(data.toJson());

class SaveChunkFile {
  SaveChunkFile({
    this.chunkTotal, // 文件总分片数量
    this.fileMd5, // 文件md5码
    this.fileName, // 文件名称
    this.fileSize, //文件大小
    this.itemList, // 文件明细
  });

  SaveChunkFile.fromJson(dynamic json) {
    chunkTotal = json['chunkTotal'];
    fileMd5 = json['fileMd5'];
    fileName = json['fileName'];
    fileSize = json['fileSize'];
    if (json['itemList'] != null) {
      itemList = [];
      json['itemList'].forEach((v) {
        itemList?.add(ItemList.fromJson(v));
      });
    }
  }

  num? chunkTotal;
  String? fileMd5;
  String? fileName;
  num? fileSize;
  List<ItemList>? itemList;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['chunkTotal'] = chunkTotal;
    map['fileMd5'] = fileMd5;
    map['fileName'] = fileName;
    map['fileSize'] = fileSize;
    if (itemList != null) {
      map['itemList'] = itemList?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}
